from sklearn.neighbors import NearestNeighbors
import numpy as np
def geteMbedding(data_test=[],data_text=""):
    data=np.load('../web/data.npy')
    data_master = np.array(data)
    data_slave = np.array(data_test)
    # 将data_master作为训练数据
    knn = NearestNeighbors(n_neighbors=3, metric='cosine')
    knn.fit(data_master)
    # 找到data_slave中每个样本与data_master中最相似样本的下标
    distances, indices = knn.kneighbors(data_slave)
    most_similar_index = indices.flatten()
    data_message=np.load('../web/data_message.npy')[most_similar_index]
    print(data_text)
    print(f"最相似的内容是: {data_message}")
    return data_message